/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package cr.ac.una.sive.converters;

import cr.ac.una.sive.entidad.Color;
import cr.ac.una.sive.entidadLocal.VehiculoLocal;
import javax.faces.component.UIComponent;
import javax.faces.context.FacesContext;
import javax.faces.convert.Converter;
import javax.faces.convert.FacesConverter;

/**
 *
 * @author claribel
 * 
 */
@FacesConverter(value="ColorConverter")
public class ColorConverter implements Converter{

    @Override
    public Object getAsObject(FacesContext context, UIComponent component, String value) {
        //throw new UnsupportedOperationException("Not supported yet.");
        
        if(value != null){
            return component.getAttributes().get(value);
            
        }
        return null;
       
    }

    @Override
    public String getAsString(FacesContext context, UIComponent component, Object value) {
        return ((Color) value).getIdColor().toString();
    }
    
}
